<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
</head>

<body>


    <script>
        function calc(n) {
            var sumNum = 0;
            for (var i = 1; i <= n; i++) {
                sumNum += i;
            }
            document.write('n=' + sumNum);
        }

        calc(window.prompt("请输入n的值"));

        var a = 20;
        var b = 50;
        var max;
        a > b ? max = a : max = b;
        console.log(max);
    </script>
</body>

</html>